package com.springboot.dubbo.user.service;

import com.springboot.dubbo.base.po.oracle.CallRecord;
import com.springboot.dubbo.user.mapper.ICallRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClassName UserServiceImpl
 * @Description: 用户微服务提供者
 * @Author 杨冬冬
 * @Date 2021/7/1 0001 1:00
 **/
@Service
public class CallRecordServiceImpl {

    @Autowired
    private ICallRecordMapper iCallRecordMapper;

    /*
     * @Author 杨冬冬
     * @Description 分布式事务插入测试
     * @Date 18:13 2021/7/2 0002
     * @param
     **/
    public void insert() throws Exception {
        CallRecord record = new CallRecord();
        record.setAgentId("测试1");
        record.setBindId("测试1");
        record.setCallId("测试1" + new Date().getTime());
        record.setIsDown(1);
        record.setJyBindId("测试1");
        record.setRecordUrl("测试1");

        int random = (int) (Math.random() * (4 - 1) + 1);
        if (random == 1) {
            throw new Exception("插入失败");
        }

        iCallRecordMapper.insert(record);
    }
}
